<?php
/*
 * 登录model
*/
namespace app\admin\model;
use think\Cache;
use \think\Model;
use \think\db;


class user extends Model
{
  protected static $tb = [
    'shop'    => 'shop',
    'user'    => 'user',

  ];

     /*
  * 获取店铺列表
  *@param data
  *@return array
  */
  public function getShopList($data=[]){
    $data['page'] = isset($data['page'])?$data['page']:1;
    $data['rows'] = isset($data['rows'])?$data['rows']:10;
    $where["s.ischeck"] = $data['ischeck']; //审核已通过
    $where["s.del_status"] = 0; //未删除
    if(isset($data['name']) && !empty($data['name'])){
      $where['s.name'] = ["like","%{$data['name']}%"];
    }
    $field = "s.id,u.username,u.pid,u.phone,s.name,s.province,s.city,s.district";
    $list =Db::name(self::$tb['shop'])->alias("s")->join("jun_user u","u.id=s.uid")
    ->where($where)->field($field)->page($data['page'],$data['rows'])->paginate(10); 
    $page = $list->render();
  /*  foreach ($list as $key => $value) { 
       $list[$key]['manage_num'] = Db::name(self::$tb['user'])->where(['shop_id'=>$value['id'],'enable'=>1])->count();
    }*/


    return array(
    	"list"=>$list,
    	"page"=>$page
    );
  }

}
